#include "effectManager.h"

effectManager* effectManager::_instance = 0;

effectManager* effectManager::Instance()
{
	if (_instance == NULL)
	{
		_instance = new effectManager();
	}
	return _instance;
}

void effectManager::draw()
{
	for (vector<Effect*>::iterator itor = manager.begin();
		itor != manager.end(); itor++)
	{
		(*itor)->draw();
	}
}

void effectManager::updata()
{
	for (vector<Effect*>::iterator itor = manager.begin();
		itor != manager.end();)
	{
		if ((*itor)->checkRemove())
		{
			delete *itor;
			itor = manager.erase(itor);
		}else
		{
			(*itor)->updata();
			itor++;
		}
	}
}

void effectManager::clear()
{
	for (vector<Effect*>::iterator itor = manager.begin();
		itor != manager.end(); itor++)
	{
		delete *itor;
	}
	vector<Effect*> t;
	manager.swap(t);
}

void effectManager::add(Effect* e)
{
	manager.push_back(e);
}